/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package library.gui;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import library.Item;

/**
 *
 * @author ryan
 */
public class ItemPane extends JPanel{
    
    private final Item i;
    public ItemPane(Item i){
      super();
      SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyy");
      this.i=i;
      setLayout(new GridLayout(1,4));
      final JLabel name = new JLabel(i.getTitle());
      final JLabel type = new JLabel(i.getType().name()); 
     
      add(name);
      add(type);
      if(i.isCheckedOut()){
        final JLabel dueDate = new JLabel(df.format(i.getDueDate()));
        add(dueDate);
        final JLabel status = new JLabel("Checked out");
        add(status);
      }      
      setToolTipText("<html><b>Title</b>:&nbsp;&nbsp;"+i.getTitle()+"<br /><b>Type</b>:&nbsp;&nbsp;"+i.getType()+"<br /><br /><b>Description</b>:<br />"+i.getDescription()+"</html>");
    }
    
    public Item getItem(){
        return i;
    }
}